from django.db import models
from blacklist.models import APK

class APKInfo(models.Model):
    apk = models.ForeignKey(APK,on_delete=models.CASCADE,related_name="apkinfo_db",verbose_name='apk')
    apk_filename = models.CharField(max_length=255)
    activities = models.JSONField()
    package = models.CharField(max_length=255)
    permissions = models.JSONField()
    app_name = models.CharField(max_length=255)
    version_name = models.CharField(max_length=50)
    version_code = models.IntegerField()
    hash_algo = models.CharField(max_length=50)
    serial_number = models.CharField(max_length=100)
    contents_der = models.TextField()
    issuer = models.CharField(max_length=255)
    md5 = models.CharField(max_length=32)
    sha1 = models.CharField(max_length=40)
    sha256 = models.CharField(max_length=64)
    validity_period = models.CharField(max_length=100)
    signature_algo = models.CharField(max_length=50)
    intent = models.JSONField()
    icon_url = models.URLField()
    apk_size = models.IntegerField()
    folder_size = models.IntegerField()

    # 处理特征
    permission_num = models.IntegerField()
    activities_num = models.IntegerField()
    intents_num = models.IntegerField()
    validdates = models.CharField(max_length=100)
    entropy_value = models.FloatField()
    ratio_before_and_after_decompression = models.FloatField()
    point_count = models.IntegerField()
    proportions_of_capital_letters = models.FloatField()
    proportions_of_lowercase_letters = models.FloatField()
    package_len = models.IntegerField()
    avg_len_beteew_point = models.FloatField()
    issuer_len = models.IntegerField()
    contents_der_len = models.IntegerField()
    hash_algo_md5 = models.BooleanField()
    hash_algo_sha1 = models.BooleanField()
    hash_algo_sha256 = models.BooleanField()
    hash_algo_sha384 = models.BooleanField()
    hash_algo_sha512 = models.BooleanField()
    signature_algo_dsa = models.BooleanField()
    signature_algo_rsassa_pkcs1v15 = models.BooleanField()

    class Meta:
        db_table = 'apkinfo_db'



class Checking(models.Model):
    file_name = models.TextField(verbose_name='file_name')
    apk = models.ForeignKey(APK,on_delete=models.CASCADE,related_name="check_db",verbose_name='apk')

    class Meta:
        verbose_name = 'check_db'